<!--
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2024-05-13 14:11:42
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2024-05-22 16:15:56
 * @FilePath: /consult-patient-vue3-ts/src/components/CpNavBar.vue
 * @Description: 
 * 
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
-->
<script setup lang="ts">
import { useRouter } from 'vue-router';

// 默认必须有返回功能
const router = useRouter()
const onClickLeft = () => {
    if (props.back) {
        return props.back()
    }
    if (history.state?.back) {
        router.back()
    } else {
        router.push('/')
    }
}
const props = defineProps<{
    title?: string,
    rightText?: string,
    back?: () => {}
}>()
const emit = defineEmits<{
    (e: 'click-right'): void
}>()
const onClickRight = () => {
    emit('click-right')
}
</script>

<template>
    <van-nav-bar :title="title" fixed left-arrow :right-text="rightText" @click-left="onClickLeft"
        @click-right="onClickRight" />
</template>

<style lang="scss" scoped>
:deep() {
    .van-nav-bar {
        &__arrow {
            font-size: 18px;
            color: var(--cp-text1);
        }

        &__text {
            font-size: 15px;
        }
    }
}
</style>
